<?php
require_once("../includes/config.inc.php");
validate_admin();
if($_POST)
{
	@extract($_POST);
	if(is_array($chkIds))
	{
		$strIds =  @implode(",",$chkIds);
		
		if($Submit == 'Active')
		{
			$sqlA = " update tbl_user set status = 1 where userId in ($strIds) ";
			executeQuery($sqlA);
			$_SESSION['sessMsg'] = " Selected Record(s) Are Now Active. ";
			header("location:userManager.php");
			exit();
		}
		
		if($Submit == 'Inactive')
		{
			$sqlA = " update tbl_user set status = 0 where userId in ($strIds) ";
			executeQuery($sqlA);
			$_SESSION['sessMsg'] = " Selected Record(s) Are Now Inactive. ";
			header("location: userManager.php");
			exit();
		}
		if($Submit == 'Mark Paid')
		{
			$sqlA = " update tbl_user set isPaid = 1 where userId in ($strIds) ";
			executeQuery($sqlA);
			$_SESSION['sessMsg'] = " Selected Record(s) Are Now Paid. ";
			header("location: userManager.php");
			exit();
		}
		
		if($Submit == 'Mark UnPaid')
		{
			$sqlA = " update tbl_user set isPaid = 0 where userId in ($strIds) ";
			executeQuery($sqlA);
			$_SESSION['sessMsg'] = " Selected Record(s) Are Now UnPaid. ";
			header("location: userManager.php");
			exit();
		}
		
		if($Submit == 'Delete')
		{
			$sqlA = " delete from tbl_user where userId in ($strIds) ";
			executeQuery($sqlA);
			
			
			$_SESSION['sessMsg'] = " Selected Record(s) Are Deleted Successfully. ";
			header("location: userManager.php");
			exit();
		}
	}
	else
	{
		$_SESSION['sessMsg'] = " Please select at least one checkbox for desire action. ";
		header("location: userManager.php");
		exit;
	}
}

/* $order_by = $_GET['order_by'];
$order_by2 = $_GET['order_by2'];

if($order_by=='') $order_by="sellerId";
if($order_by2=='') $order_by2="desc"; */
$listPaging = $_REQUEST['listPaging'];
if($page == '') { $page = 1; }
if($pagegroup == '') { $pagegroup = 1; }
if(trim($listPaging) == '') { $listPaging = 20; }

$sqlPL = " select * from tbl_user where 1 = 1   ";

@extract($_REQUEST);

$sqlPL.= concatSql($isSql=false,$sqlVal='',$tblField='firstName',$requestField='sFirstName',$method='get',$whCondition='and',$whOpreator='like');
$sqlPL.= concatSql($isSql=false,$sqlVal='',$tblField='lastName',$requestField='sLastName',$method='get',$whCondition='and',$whOpreator='like');
$sqlPL.= concatSql($isSql=false,$sqlVal='',$tblField='email',$requestField='sEmailAddress',$whCondition='get',$andOr='and',$type='like');
$sqlPL.=" order by userId desc";

$resPL = executeQuery(dopaging($sqlPL,$listPaging));
?>